const path = require('path')
module.exports = {
  rootDir: path.resolve(__dirname, './'),
  moduleFileExtensions: [
    'js',
    'jsx',
    'json',
    'vue'
  ],
  verbose: true,
  //   testEnvironment: 'jest-environment-jsdom',
  moduleDirectories: ['node_modules', '<rootDir>/src'],
  setupFiles: ['<rootDir>/tests/unit/lib/register-context.js'], // 每次测试文件执行
  transform: {
    '^.+\\.vue$': '<rootDir>/node_modules/vue-jest',
    '.+\\.(css|styl|less|sass|scss|svg|png|jpg|ttf|woff|woff2)$': '<rootDir>/node_modules/jest-transform-stub',
    '^.+\\.(jsx|js)$': '<rootDir>/node_modules/babel-jest'
    // '^.+\\.svg?inline$': '<rootDir>/node_modules/jest-svg-transformer'
  },
  moduleNameMapper: {
    '^@/(.*)$': '<rootDir>/src/$1',
    '^tests/(.*)$': '<rootDir>/tests/$1'
    // eslint-disable-next-line max-len
    // '\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': '<rootDir>/__mocks__/fileMock.js',
    // '\\.(css|less|scss|sss|styl)$': '<rootDir>/__mocks__/styleMock.js'
  },
  snapshotSerializers: [
    'jest-serializer-vue'
  ],
  testMatch: [
    '**/tests/unit/**/*.spec.(js|jsx|ts|tsx)|**/__tests__/*.(js|jsx|ts|tsx)'
  ],
  transformIgnorePatterns: [
    '<rootDir>/node_modules/(?!(ant-design-vue|element-ui|bpmn-js|diagram-js))'
  ],
  testResultsProcessor: 'jest-sonar-reporter',
  testURL: 'http://localhost/',
  collectCoverage: true,
  collectCoverageFrom: [
    '**/src/**/*.{js,vue}',
    '!**/node_modules/**',
    '!**/src/main.js',
    '!**/src/router/index.js',
    '!**/src/api/**'
  ]
}
